#include <bits/stdc++.h>
using namespace std;
int a[1000006];
int n, m; // N树，需要M米
int cut(long long mid)
{
    long long s = 0;
    int i;
    for (i = 1; i <= n; i++)
    {
        if (a[i] > mid) // 树高度 > 锯点高度
        {
            s += a[i] - mid;
        }
    }
    if (s >= m)
        return 1; // 总木材 > M米
    else
        return 0; // 总木材 < M米
}
int main()
{
    long long  i, maxh, L, H, mid, cutpoint;
    maxh = 0;
    cutpoint = 0;
    cin >> n >> m;
    for (i = 1; i <= n; i++)
    {
        cin >> a[i];
        if (a[i] > maxh)
        {
            maxh = a[i];
        }
    }
    L = 0;
    H = maxh;
    while (L <= H)
    {
        mid = (L + H) / 2; // 中间下标
        if (cut(mid) == 1)
        {
            cutpoint = mid;
            L = mid + 1;
        }
        else
        {
            H = mid - 1;
        }
    }
    cout << cutpoint << endl;
    return 0;
}
/*
输入：
4 7
20 12 10 17

输出：
15
*/